package com.jsu.controller;

import com.jsu.service.FlowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.models.auth.In;
import org.example.model.activity.dto.AcFlowWithSpeakerDTO;
import org.example.model.activity.dto.ActFlowDTO;
import org.example.model.activity.dto.FlowDTO;
import org.example.model.activity.dto.FlowWithSpeakerDTO;
import org.example.model.activity.pojo.FlowSpeaker;
import org.example.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/flow")
@Api(tags = "议程流程控制器")
public class FlowController {
    @Autowired
    private FlowService flowService;

    @GetMapping("/getAllFlows")
    @ApiOperation(value = "查询所有流程")
    public ResponseResult getAllFlows(){
        return flowService.getAllFlows();
    }

    @GetMapping("/getAllFlowsAct")
    @ApiOperation(value = "查询活动的流程")
    public ResponseResult getAllFlowsAct(){
        return flowService.getAllFlowsAct();
    }

    @GetMapping("/getFlow/{agenda_id}")
    @ApiOperation(value = "根据议程id查询该议程的流程信息")
    public ResponseResult getFlowByAgendaId(@ApiParam("议程id") @PathVariable("agenda_id")Integer id){
        return flowService.getFlowByAgendaId(id);
    }

    @PutMapping("/updateFlow")
    @ApiOperation(value = "更新流程信息")
    public ResponseResult updateFlow(@ApiParam("流程信息") @RequestBody FlowWithSpeakerDTO flowInfo){
        return flowService.updateFlow(flowInfo);
    }


    @DeleteMapping("/deleteFlow")
    @ApiOperation(value = "删除流程信息")
    public ResponseResult deleteFlow(Integer flowId){
        return flowService.deleteFlow(flowId);

    }

    @PostMapping("/addFlow")
    @ApiOperation(value = "新增流程信息")
    public ResponseResult addFlow(@ApiParam("流程信息") @RequestBody FlowDTO flowInfo){
        return flowService.addFlow(flowInfo);
    }

    @PutMapping("/updateFlowAct")
    @ApiOperation(value = "更新活动流程信息")
    public ResponseResult updateFlowAct(@ApiParam("流程信息") @RequestBody AcFlowWithSpeakerDTO flowInfo){
        return flowService.updateFlowAct(flowInfo);
    }


    @DeleteMapping("/deleteFlowAct")
    @ApiOperation(value = "删除流程信息")
    public ResponseResult deleteFlowAct(Integer flowId){
        return flowService.deleteFlowAct(flowId);

    }

    @PostMapping("/addFlowAct")
    @ApiOperation(value = "新增流程信息")
    public ResponseResult addFlowAct(@ApiParam("流程信息") @RequestBody ActFlowDTO flowInfo){
        return flowService.addFlowAct(flowInfo);
    }

}
